﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<volva.Models.Video>" %>
<%@ Import Namespace="volva.Models" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <% 
        int rating = 0;
        if (Model.ratingCount > 0)
            rating = (int)Math.Round((decimal)(Model.ratingSum / Model.ratingCount)); 
    %>


    <h1><%=Html.Encode(Model.name) %></h1>
    <div id="video">
	<div id="embeddedVideo">
	<object width="640" height="360"><param name="movie" value="http://www.youtube.com/v/<%= Model.embeddCode %>&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/<%= Model.embeddCode %>&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="360"></embed></object>
	</div>
	<div id="toolbar" class="clearfix">
	    <div id="rate" class="hoverpop">
		<a href="#" class="hover">Einkunn</a>
		<div class="popdown">
		    <a href="/Station/GiveVideoRating/?videoId=<%= (Model.id) %>&rating=1" class="<%= (rating >= 1 ? "starfull" : "staropen") %>" title="Gefa þættinum 1 stjörnu"></a>
		    <a href="/Station/GiveVideoRating/?videoId=<%= (Model.id) %>&rating=2" class="<%= (rating >= 2 ? "starfull" : "staropen") %>" title="Gefa þættinum 2 stjörnur"></a>
		    <a href="/Station/GiveVideoRating/?videoId=<%= (Model.id) %>&rating=3" class="<%= (rating >= 3 ? "starfull" : "staropen") %>" title="Gefa þættinum 3 stjörnur"></a>
		    <a href="/Station/GiveVideoRating/?videoId=<%= (Model.id) %>&rating=4" class="<%= (rating >= 4 ? "starfull" : "staropen") %>" title="Gefa þættinum 4 stjörnur"></a>
		    <a href="/Station/GiveVideoRating/?videoId=<%= (Model.id) %>&rating=5" class="<%= (rating == 5 ? "starfull" : "staropen") %>" title="Gefa þættinum 5 stjörnur"></a><br clear="all" />
		    <span class="text"><%= rating %> af 5</span>
		</div>
	    </div>
	    <div id="bookmark">
		<a href="javascript:if(document.all)window.external.AddFavorite(location.href,document.title);else%20if(window.sidebar)window.sidebar.addPanel(document.title,location.href,'');" class="hover">Bókmerkja</a>
	    </div>

	    <div id="views">
		<strong><%= Html.Encode(Model.viewCount) %></strong> áhorf
	    </div><br clear="all" />
	    <div id="series">
		Þessi þáttur er hluti af þáttarröðinni <a href="/Home/Series/<%= (Model.Series.id) %>" class="series"><%Response.Write(Model.Series.name); %></a>
	    </div>
	</div>
	<div id="info">
	    <div id="description" class="clickpop">
		<h3><a href="#" class="click">Lýsing þáttarins</a></h3>
		<p class="popdown"><%= Model.description%></p>
	    </div>
	    <div id="comments" class="clickpop">
		<h3><a href="#" class="click">Athugasemdir</a></h3>
		<div class="popdown">
		    <form action="/Home/MakeComment/<%= (Model.id) %>" method="post">
		        <input type="text" id="comment" name="comment" class="text" />
		        <input type="submit" value="Skrá" class="btn" />
		    </form>
<%
    List<Comment> comment = ViewData["comment"] as List<Comment>;
    if (comment != null)
    {
    %>
                <table>
                <tr>
                    <th>Atugasemdir</th>
                    <th>Notendanafn</th>
                    <th>Dagssetning</th>
                </tr>
            
            <%
            int j = 0;
            foreach (Comment c in comment)
            {
                Response.Write("<tr class='" + (j % 2 == 0 ? "even" : "odd") + "'>");
                Response.Write("<td>" + c.comment1 + "</td><td>" + c.WebUser.username + "</td><td>" + c.commentTime + "</td>");
                Response.Write("</tr>");
                j++;
            }
        }

    else
        Response.Write("Ekkert comment!");

                    %>
    </table>
		</div>
	    </div>
	</div>
    </div>
    <div id="related">
	<table>
	    <caption>Vinsælasti þátturinn í gangi</caption>
	    <tr><td><% 
			Video v = (ViewData["MostPopularVideos"] as List<Video>).FirstOrDefault();
            if (v != null)
            {
                Response.Write("<a href=\"/Home/Watch/" + v.id + "\">" + v.name + "</a> - ");
                Response.Write("<a href=\"/Station/Details/" + v.Station_id + "\">" + v.Station.name + "</a>");
            }
		%></td></tr>
	</table>
	<!--<table>
	<caption>Næstu þættir á dagsskrá</caption>
	    <tr>
	    <td></td>
	    </tr>
	</table>-->
    </div>
</asp:Content>

